import CrudService from '../global/CrudService'

let instance = null

// 后端路径
const prefix = '/project'

class Service extends CrudService {
	constructor() {
		super(prefix)
		this.getListPath = `${ prefix }/doProjectList`
		this.addPath = `${ prefix }/doProjectInsert`
		this.deletePath = `${ prefix }/doProjectDel`
		this.updatePath = `${ prefix }/doProjectUpdate`
		return instance || this
	}
	
	
	static getInstance() {
		if (!instance) {
			instance = new Service()
		}
		return instance
	}
	
	queryTemplateList_single = async (model) => {
		const result = await this.get(`/rptTemplate/queryTemplateList_single`, model)
		return Array.isArray(result) && result.map(item => ({
			...item,
			key  : item.id,
			value: item.template_name
		}))
	}
	
	//归档
	doProjectCommit = async (model) => {
		const query = this.qs(model)
		return await this.post(`${ prefix }/doProjectCommit?${query}`, model)
		
	}
	
	getProjItem(id) {
		if (id) {
			return this.get(`${ prefix }/${ id }`)
		}
	}
}

export default Service.getInstance()
